//
//  GCHelper.h
//  Game Center
//
//  Created by admin on 3/28/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>
#import <Foundation/NSObjCRuntime.h>
#import <Foundation/NSZone.h>
@protocol GCHelperDelegate
@optional
- (void)matchStarted;
- (void)matchEnded;
- (void)match:(GKMatch*)match didReceiveData:(NSData *)data 
   fromPlayer:(NSString *)playerID;

- (void) scoreReported: (NSError*) error;
- (void) reloadScoresComplete: (GKLeaderboard*) leaderBoard error: (NSError*) error;

- (void) submitAchievementsComplete:(GKAchievement*) achievement error: (NSError*) error;

- (void)inviteReceived;
@end

@interface GCHelper : NSObject<GKMatchmakerViewControllerDelegate, GKMatchDelegate>
{
    BOOL gameCenterAvailable;
    BOOL userAuthenticated;
    
    UIViewController* presentingViewController;
    GKMatch* match;
    BOOL matchStarted;
    id <GCHelperDelegate> delegate;
    
    NSMutableDictionary *playersDict;
    
    NSMutableDictionary* achievementsDictionary;
    
    GKInvite *pendingInvite;
    NSArray *pendingPlayersToInvite;
}
@property (assign, readonly) BOOL gameCenterAvailable;

@property (retain) UIViewController *presentingViewController;
@property (retain) GKMatch *match;
@property (assign) id <GCHelperDelegate> delegate;

@property(nonatomic, retain) NSMutableDictionary* playersDict;

@property(nonatomic, retain) NSMutableDictionary* achievementsDictionary;

@property (retain) GKInvite *pendingInvite;
@property (retain) NSArray *pendingPlayersToInvite;

+ (GCHelper *)sharedInstance;
- (void)authenticateLocalUser;

- (void)findMathWithMinPlayers:(int)minPlayers 
                    maxPlayers:(int)maxPlayers 
                viewController:(UIViewController*)viewController 
                      delegate:(id<GCHelperDelegate>) theDelegate;

- (void) reportScore: (int64_t) score forCategory: (NSString*) category;
- (void) reloadHighScoresForCategory: (NSString*) category;

- (void) loadAchievements;
- (GKAchievement *)getAchievementForIdentifier:(NSString *)identifier;
- (void)reportAchievementIdentifier:(NSString *)identifier incrementPercentComplete:(float)percent;
- (void)reportAchievementIdentifier:(NSString *)identifier percentComplete:(float)percent;

-(void)getCurrentLeaderboardScore:(NSString *)Category withCalculatedScore:(int)calculatedScore;

@end
